﻿using Kogel.Dapper.Extension.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IdentityService.Domain.Entities
{
    [Display(Rename = "user_role")]
    public class UserRole
    {
        /// <summary>
        /// ID
        /// </summary>
        [Display(Rename = "id")]
        [Identity]
        public int Id { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        [Display(Rename = "role_name")]
        public required string RoleName { get; set; }

        /// <summary>
        /// ID
        /// </summary>
        [Display(Rename = "user_id")]
        public long UserID { get; set; }

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <returns></returns>
        public static UserRole Create(User user, string roleName)
        {
            UserRole item = new()
            {
                RoleName = roleName,
                UserID = user.Id,
            };
            return item;
        }
    }
}
